#include "drv_iwdt.h"
#include "hc32f460_wdt.h"
#include <stdio.h>

void iwdt_feed_dog(void){
	WDT_RefreshCounter();
}

void iwdt_init(void){
	stc_wdt_init_t stcWdtInit;
	stc_rmu_rstcause_t stcRmuRstCause;
	MEM_ZERO_STRUCT(stcRmuRstCause);
	RMU_GetResetCause(&stcRmuRstCause);
//	RMU_ClrResetFlag();	
	MEM_ZERO_STRUCT(stcWdtInit);
	stcWdtInit.enClkDiv = WdtPclk3Div1024;   //时钟分频 
	stcWdtInit.enCountCycle = WdtCountCycle16384;//WdtCountCycle16384;  //计数周期
	stcWdtInit.enRefreshRange = WdtRefresh0To100Pct;  //允许刷新百分比0-100%
	stcWdtInit.enSleepModeCountEn = Disable;         //在休眠模式是否使能计数
	stcWdtInit.enRequestType = WdtTriggerResetRequest;  //刷新错误或者计数下溢触发复位
	WDT_Init(&stcWdtInit);	
	
	WDT_RefreshCounter();
    Ddl_Delay1ms(200);
}
